﻿using System;
using System.Collections.Generic;
using System.Linq;
using Benecura.Data.Model;
using Benecura.Data.Repository.Common;
using Benecura.Data.Repository.Context;

namespace Benecura.Data.Repository
{
    public class EventRepository : DotNetDream.Data.Helper.EntityFramework.RepositoryBase<MasterContext>, IEventRepository
    {
        /// <summary>
        /// Get an Event by Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Event GetEvent(int id)
        {
            return Select<Event>(e => e.Id == id).FirstOrDefault();
        }

        /// <summary>
        /// Get the list of Events satisfy the lambda condition
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public List<Event> GetMoreEvents(System.Linq.Expressions.Expression<Func<Event, bool>> condition)
        {
            return Select<Event>(condition).ToList();
        }
    }
}
